class SystemAjaxConfig {
    constructor(url, type) {
        this.url = url;
        this.method = type ? type : 'post';
        this.dataType = 'json';
        this.data = {};
        this.sort = true;
        this.showLoad = true;
    }

    setData(data) {
        this.data = data;
        return this;
    }
    setParams(params) {
        this.params = params;
        return this;
    }
    isPost() {
        this.method = 'POST';
        return this;
    }
    noLoad() {
        this.showLoad = false;
        return this;
    }
    send () {
        if (this.showLoad) {
            this._loadIndex = layer.load(3, {shade: 0.3});
        }
        let p=axios(this),that=this;
        p.finally(function(){
            if (that.showLoad) {
                layer.close(that._loadIndex);
            }
        });
        return p;
    }
    set (k, v) {
        this[k] = v;
        return this;
    }
}

export default SystemAjaxConfig
